home *** CD-ROM | disk | FTP | other *** search
/ Chip 2006 June / CHIP 2006-06.2.iso / program / freeware / Democracy-0.8.2.exe / xulrunner / python / BitTorrent / defaultargs.py < prev    next >
Encoding:
Python Source  |  2006-04-10  |  8.2 KB  |  164 lines

  1. # The contents of this file are subject to the BitTorrent Open Source License
  2. # Version 1.0 (the License).  You may not copy or use this file, in either
  3. # source code or executable form, except in compliance with the License.  You
  4. # may obtain a copy of the License at http://www.bittorrent.com/license/.
  5. #
  6. # Software distributed under the License is distributed on an AS IS basis,
  7. # WITHOUT WARRANTY OF ANY KIND, either express or implied.  See the License
  8. # for the specific language governing rights and limitations under the
  9. # License.
  10.  
  11. common_options = [
  12.     ('ip', '',
  13.         "ip to report to the tracker (has no effect unless you are on the same local network as the tracker)"),
  14.     ('forwarded_port', 0,
  15.         "world-visible port number if it's different from the one the client "
  16.         "listens on locally"),
  17.     ('minport', 6881, 'minimum port to listen on, counts up if unavailable'),
  18.     ('maxport', 6999, 'maximum port to listen on'),
  19.     ('bind', '',
  20.         'ip to bind to locally'),
  21.     ('display_interval', .5,
  22.         'seconds between updates of displayed information'),
  23.     ('rerequest_interval', 5 * 60,
  24.         'minutes to wait between requesting more peers'),
  25.     ('min_peers', 20,
  26.         'minimum number of peers to not do rerequesting'),
  27.     ('max_initiate', 40,
  28.         'number of peers at which to stop initiating new connections'),
  29.     ('max_allow_in', 80,
  30.         'maximum number of connections to allow, after this new incoming connections will be immediately closed'),
  31.     ('check_hashes', 1,
  32.         'whether to check hashes on disk'),
  33.     ('max_upload_rate', 20,
  34.         'maximum kB/s to upload at, 0 means no limit'),
  35.     ('min_uploads', 2,
  36.         "the number of uploads to fill out to with extra optimistic unchokes"),
  37.     ('data_dir', '',
  38.          "directory under which variable data such as fastresume information "
  39.          "and GUI state is saved. Defaults to subdirectory 'data' of the "
  40.          "bittorrent config directory."),
  41.     ('max_files_open', 50,
  42.      'the maximum number of files in a multifile torrent to keep open at a time, 0 means no limit. Used to avoid running out of file descriptors.'),
  43.     ]
  44.  
  45.  
  46. rare_options = [
  47.     ('keepalive_interval', 120.0,
  48.         'number of seconds to pause between sending keepalives'),
  49.     ('download_slice_size', 2 ** 14,
  50.         "how many bytes to query for per request."),
  51.     ('max_message_length', 2 ** 23,
  52.         "maximum length prefix encoding you'll accept over the wire - larger values get the connection dropped."),
  53.     ('timeout', 300.0,
  54.         'seconds to wait between closing sockets which nothing has been received on'),
  55.     ('timeout_check_interval', 60.0,
  56.         'seconds to wait between checking if any connections have timed out'),
  57.     ('max_slice_length', 16384,
  58.         "maximum length slice to send to peers, close connection if a larger request is received"),
  59.     ('max_rate_period', 20.0,
  60.         "maximum amount of time to guess the current rate estimate represents"),
  61.     ('max_rate_period_seedtime', 100.0,
  62.         "maximum amount of time to guess the current rate estimate represents"),
  63.     ('max_announce_retry_interval', 1800,
  64.         'maximum time to wait between retrying announces if they keep failing'),
  65.     ('snub_time', 30.0,
  66.         "seconds to wait for data to come in over a connection before assuming it's semi-permanently choked"),
  67.     ('rarest_first_cutoff', 4,
  68.         "number of downloads at which to switch from random to rarest first"),
  69.     ('upload_unit_size', 1380,
  70.         'how many bytes to write into network buffers at once.'),
  71.     ('retaliate_to_garbled_data', 1,
  72.      'refuse further connections from addresses with broken or intentionally '
  73.      'hostile peers that send incorrect data'),
  74.     ('one_connection_per_ip', 1,
  75.      'do not connect to several peers that have the same IP address'),
  76.     ('peer_socket_tos', 8,
  77.      'if nonzero, set the TOS option for peer connections to this value'),
  78.     ('filesystem_encoding', '',
  79.      "character encoding used on the local filesystem. If left empty, autodetected. Autodetection doesn't work under python versions older than 2.3"),
  80.     ('enable_bad_libc_workaround', 0,
  81.      'enable workaround for a bug in BSD libc that makes file reads very slow.'),
  82.     ('tracker_proxy', '',
  83.      'address of HTTP proxy to use for tracker connections'),
  84.     ]
  85.  
  86. def get_defaults(ui):
  87.     assert ui in "btdownloadheadless btdownloadcurses btdownloadgui " \
  88.            "btlaunchmany btlaunchmanycurses btmaketorrentgui".split()
  89.  
  90.     r = list(common_options)
  91.  
  92.     if ui == 'btdownloadgui':
  93.         r.extend([
  94.             ('save_as', '',
  95.              'file name (for single-file torrents) or directory name (for batch torrents) to save the torrent as, overriding the default name in the torrent. See also --save_in, if neither is specified the user will be asked for save location'),
  96.             ('advanced', 0,
  97.              "display advanced user interface"),
  98.             ('next_torrent_time', 300,
  99.              'the maximum number of minutes to seed a completed torrent before stopping seeding'),
  100.             ('next_torrent_ratio', 80,
  101.              'the minimum upload/download ratio, in percent, to achieve before stopping seeding. 0 means no limit.'),
  102.             ('last_torrent_ratio', 0,
  103.              'the minimum upload/download ratio, in percent, to achieve before stopping seeding the last torrent. 0 means no limit.'),
  104.             ('pause', 0,
  105.              'start downloader in paused state'),
  106.             ('dnd_behavior', 'replace',
  107.              ''),
  108.             ])
  109.  
  110.     if ui in ('btdownloadcurses', 'btdownloadheadless'):
  111.         r.append(
  112.             ('save_as', '',
  113.              'file name (for single-file torrents) or directory name (for batch torrents) to save the torrent as, overriding the default name in the torrent. See also --save_in'))
  114.  
  115.     if ui.startswith('btdownload'):
  116.         r.extend([
  117.             ('max_uploads', -1,
  118.              "the maximum number of uploads to allow at once. -1 means a (hopefully) reasonable number based on --max_upload_rate. The automatic values are only sensible when running one torrent at once."),
  119.             ('save_in', '',
  120.              'local directory where the torrent contents will be saved. The file (single-file torrents) or directory (batch torrents) will be created under this directory using the default name specified in the .torrent file. See also --save_as.'),
  121.             ('responsefile', '',
  122.              'file the server response was stored in, alternative to url'),
  123.             ('url', '',
  124.              'url to get file from, alternative to responsefile'),
  125.             ('ask_for_save', 0,
  126.              'whether or not to ask for a location to save downloaded files in'),
  127.             ])
  128.  
  129.     if ui.startswith('btlaunchmany'):
  130.         r.extend([
  131.             ('max_uploads', 6,
  132.              "the maximum number of uploads to allow at once. -1 means a (hopefully) reasonable number based on --max_upload_rate. The automatic values are only sensible when running one torrent at once."),
  133.             ('save_in', '',
  134.              'local directory where the torrents will be saved, using a name determined by --saveas_style. If this is left empty each torrent will be saved under the directory of the corresponding .torrent file'),
  135.             ('parse_dir_interval', 60,
  136.               "how often to rescan the torrent directory, in seconds" ),
  137.             ('saveas_style', 1,
  138.               "How to name torrent downloads (1 = rename to torrent name, " +
  139.               "2 = save under name in torrent, 3 = save in directory under torrent name)" ),
  140.             ('display_path', ui == 'btlaunchmany' and 1 or 0,
  141.               "whether to display the full path or the torrent contents for each torrent" ),
  142.             ])
  143.  
  144.     if ui.startswith('btlaunchmany') or ui == 'btmaketorrentgui':
  145.         r.append(
  146.             ('torrent_dir', '',
  147.              'directory to look for .torrent files (semi-recursive)'),)
  148.  
  149.     if ui in ('btdownloadcurses', 'btdownloadheadless'):
  150.         r.append(
  151.             ('spew', 0,
  152.              "whether to display diagnostic info to stdout"))
  153.  
  154.     if ui == 'btmaketorrentgui':
  155.         r.extend([
  156.             ('piece_size_pow2', 18,
  157.              "which power of two to set the piece size to"),
  158.             ('tracker_name', 'http://my.tracker:6969/announce',
  159.              "default tracker name"),
  160.             ])
  161.  
  162.     r.extend(rare_options)
  163.     return r
  164.